<%@ page language="java" contentType="text/html; charset=UTF8"
    pageEncoding="UTF8"%>
<%@page import="org.springframework.web.context.request.SessionScope"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>      
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF8">
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>  
    <title>users</title>  
<link rel="stylesheet" type="text/css" href="common/css/allUser.css">
<link rel="stylesheet" href="common/css/pintuer.css">
<script type="text/javascript" src="component/jquery1.4.4.js"></script>	
<script type="text/javascript" src="common/js/user/allUser.js"></script>
</head>
<body>

	<div class="panel admin-panel">
		<div class="panel-head" style="text-align:center"><strong >UserList</strong></div>
		<div class="padding border-bottom" >
			<span id="userSearch" style="dispaly:inline" style="align:left">
				<form style="display:inline" action="userSearch.action?number=1">
					<input name="number" type="hidden" value=1 />
		     		<input id="userStatusHidden" type="hidden" value="${sessionScope.userStatus}" />
		     		<input id="loginErrorTimesHidden" type="hidden" value="${sessionScope.loginErrorTimes}" />
		     		<input id="roleHidden" type="hidden" value="${sessionScope.role}" />
					<label style="margin-left:20px">userName</label>
					<input name="userName" id="userName" type="text" class="input" placeholder="Enter keywords" style="display:inline;width:130px;" value="${userName}">
					<label style="margin-left:20px">Phone</label>
					<input name="phone" id="phone" type="text" class="input" placeholder="Enter keywords" style="display:inline;width:130px" value="${phone}">
					<label style="margin-left:20px">Email</label>
					<input name="email" id="email" type="text" class="input" placeholder="Enter keywords" style="display:inline;width:150px" value="${email}">
					<label style="margin-left:20px">Status</label>
					<select name="userStatus" class="input" id="userStatus" style="display:inline;width:100px">
						<option id="status2" value="2">All</optioin> 
						<option id="status0" value="0">InActivated</optioin> 
						<option id="status1" value="1">Activated</optioin>
					</select>
					<label style="margin-left:20px">ErrorTimes</label>
					<select name="loginErrorTimes" class="input" style="display:inline;width:50px" id="loginErrorTimes">
						<option id="loginErrorTimes4" value="4">All</optioin>
						<option id="loginErrorTimes0" value="0">0</optioin>
						<option id="loginErrorTimes1" value="1">1</optioin> 
						<option id="loginErrorTimes2" value="2">2</optioin>
						<option id="loginErrorTimes3" value="3">3</optioin>
					</select>
					<label style="margin-left:20px">Role</label>
					<select name="role" class="input" class="input" style="display:inline;width:145px" id="role">
						<option id="role0" value="0">All</optioin>
						<option id="role1" value="1">SuperAdministrator</optioin>
						<option id="role2" value="2">ITAdministrator</optioin> 
						<option id="role3" value="3">Librarian</optioin>
						<option id="role4" value="4">Announcement</optioin>
						<option id="role5" value="5">VIPUsers</optioin>
						<option id="role6" value="6">GeneralUser</optioin>
					</select>
					<br>
					<br>
					<label style="margin-left:20px">pwTime</label>
					<input name="timeStart" class="input" style="display:inline;width:160px" id="timeStart" type="date"  value="${sessionScope.timeStart}"><label style="margin-left:10px">To</label>
					<input name="timeEnd" class="input" style="display:inline;width:160px" id="timeEnd" type="date"  value="${sessionScope.timeEnd}">
					<button type="submit" style="margin-left:10px" class="button button-small border-blue" >Search</button>
				</form>
			</span>
			<button type="button" class="button button-small border-yellow " style="margin-left:10px" value="Add" onclick="window.location.href='registerView.action'" >&nbsp;ADD&nbsp;</button>
		</div>
	<table class="table table-hover" style="table-layout:fixed">  
		<tr>
			<th width="30" style="text-align:center">No</th>  
			<th width="50" style="text-align:center">ID</th>  
			<th width="80" style="text-align:center">NAME</th>  
			<th width="100" style="text-align:center">PASSWOED</th>
			<th width="100" style="text-align:center">PHONE</th>
			<th width="150" style="text-align:center">EMAIL</th>
			<th width="80" style="text-align:center">ADDRESS</th>
			<th width="110" style="text-align:center">ROLE</th>
			<th width="100" style="text-align:center">PWTIME</th>
			<th width="80" style="text-align:center">STATUS</th>
			<th width="80" style="text-align:center">ERRORTIMES</th>
			<th width="100" style="text-align:center">OPERATION</th>
		</tr>
		<% Integer listCountNumber = (Integer)session.getAttribute("number");
		listCountNumber=listCountNumber*6-5;%>   
		<c:if test="${!empty userList }">  
			<c:forEach items="${userList}" var="user">  
				<tr>
					<td style="text-align:center"><%=listCountNumber++ %></td>  
					<td style="text-align:center;white-space:nowrap;overflow:hidden">${user.user_id }</td>  
					<td style="text-align:center;white-space:nowrap;overflow:hidden">${user.user_name }</td>
					<td style="text-align:center;white-space:nowrap;overflow:hidden">${user.user_password }</td>  
					<td style="text-align:center;white-space:nowrap;overflow:hidden">${user.user_cellphone }</td>  
					<td style="text-align:center;white-space:nowrap;overflow:hidden">${user.user_email }</td>  
					<td style="text-align:center;white-space:nowrap;overflow:hidden">${user.user_address }</td>  
					<td style="text-align:center;white-space:nowrap;overflow:hidden">
						<c:if test= "${user.user_roleId==1}">
 							<c:out value="SuperAdministrator"/>
						</c:if>
						<c:if test= "${user.user_roleId==2}">
							<c:out value="ITAdministrator"/>
						</c:if>
						<c:if test= "${user.user_roleId==3}">
							<c:out value="Librarian"/>
						</c:if>
						<c:if test= "${user.user_roleId==4}">
							<c:out value="Announcement"/>
						</c:if>
						<c:if test= "${user.user_roleId==5}">
							<c:out value="VIPUsers"/>
						</c:if>
						<c:if test= "${user.user_roleId==6}">
							<c:out value="GeneralUser"/>
						</c:if>
					</td style="text-align:center;white-space:nowrap;overflow:hidden">
					<td><fmt:formatDate value="${user.pwCreatTime}" pattern="yyyy-MM-dd"/></td>
						<td style="text-align:center;white-space:nowrap;overflow:hidden">
							<c:if test= "${user.user_flag==1}">
								<c:out value="activated"/>
							</c:if>
							<c:if test= "${user.user_flag==0}">
								<c:out value="inactivated"/>
							</c:if>
						</td>
						<td style="text-align:center;white-space:nowrap;overflow:hidden">${user.loginErrorTimes }</td>
						<td style="text-align:center">  
							<button type="button" class="button border-blue button-little" id="back" onclick= "window.location='getUser.action?id=${user.user_id}'">EDIT</button> 
							<button type="button" class="button border-yellow button-little" id="back" onclick= "window.location='delete.action?id=${user.user_id}'">DELETE</button>        
						</td>  
				</tr>               
			</c:forEach>  
		</c:if>  
	</table>
	<div class="panel-foot text-right" style="margin-right:20px">
		<ul class="pagination"><li><a href="userSearch.action?number=1&userStatus=${sessionScope.userStatus}&phone=${sessionScope.phone}&email=${sessionScope.email}&loginErrorTimes=${sessionScope.loginErrorTimes}&role=${sessionScope.role}&timeStart=${sessionScope.timeStart}&timeEnd=${sessionScope.timeEnd}&userName=${sessionScope.userName}"><spring:message code="FirstPage"/></a></li></ul>
		<ul class="pagination"><li><a href="userSearch.action?number=${sessionScope.number-1}&userStatus=${sessionScope.userStatus}&phone=${sessionScope.phone}&email=${sessionScope.email}&loginErrorTimes=${sessionScope.loginErrorTimes}&role=${sessionScope.role}&timeStart=${sessionScope.timeStart}&timeEnd=${sessionScope.timeEnd}&userName=${sessionScope.userName}"><spring:message code="Last"/></a></li></ul>
		<ul class="pagination"><li><a href="userSearch.action?number=${sessionScope.number+1}&userStatus=${sessionScope.userStatus}&phone=${sessionScope.phone}&email=${sessionScope.email}&loginErrorTimes=${sessionScope.loginErrorTimes}&role=${sessionScope.role}&timeStart=${sessionScope.timeStart}&timeEnd=${sessionScope.timeEnd}&userName=${sessionScope.userName}"><spring:message code="Next"/></a></li></ul>
		<ul class="pagination"><li><a href="userSearch.action?number=${sessionScope.count}&userStatus=${sessionScope.userStatus}&phone=${sessionScope.phone}&email=${sessionScope.email}&loginErrorTimes=${sessionScope.loginErrorTimes}&role=${sessionScope.role}&timeStart=${sessionScope.timeStart}&timeEnd=${sessionScope.timeEnd}&userName=${sessionScope.userName}"><spring:message code="Final"/></a></li></ul>
		<font style="line-height:2.5"><spring:message code="currentpage"/>${sessionScope.number}/${sessionScope.count}</font>
	</div>
	</div>
</body>
</html>